import request from '@/utils/request'
import { baseUrl } from '@/config/env';

//获取角色列表
export const getRoleTreeList = () => {
  return request({
    url:baseUrl+'/rest/role/roleTreeList',
    method:'get'
  })
}

export const getRolesTree = (userId) => {
  return request({
    url: `${baseUrl}/rest/role/roleTreeListByUserId/${userId}`,
    method: 'post'
  })
}

export const setMenu = (roleId, ids) => {
  return request({
    url: baseUrl+'/rest/role/setAuthority',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      roleId,
      ids
    }
  })
}
export const getList = (page, size, params) => {
  return request({
    url: baseUrl+'/rest/role/list',
    method: 'get',
    params: {
      ...params,
      page,
      size,
    }
  })
}
export const remove = (roleId) => {
  return request({
    url: baseUrl+'/rest/role/remove',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      roleId,
    }
  })
}

export const add = (row) => {
  return request({
    url: baseUrl+'/rest/role/add',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: row
  })
}

export const update = (row) => {

  console.log("-----ajax参数选择---------")
  console.log(row)

  return request({
    url: baseUrl+'/rest/role/edit',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: row
  })
}

export const getRole = (roleId) => {
  return request({
    url: `${baseUrl}/rest/role/view/${roleId}`,
    method: 'post'
  })
}